import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter);

const index = ()=> import("../views/index");
const newDetail = ()=> import("../views/newDetail");
const routes = [
    {
        path: '/',
        name: 'index',
        component: index,
        meta: {
            title: '资讯'
        }
    },
    {
        path: '/newDetail',
        name: 'newDetail',
        component: newDetail,
        meta: {
            title: '新闻详情'
        }
    }
];

const router = new VueRouter({
    //mode: 'history',
    linkActiveClass: 'active',
    base: process.env.BASE_URL,
    routes
});


//路由后置钩子
router.afterEach((to, from) => {

    //设置头部标题
    if (to.meta.title) document.title = to.meta.title;
});

export default router




